package com.example.cms.web.Controller;

import com.example.cms.Service.IUploadService;
import com.example.common.web.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/11/4-11-04-10:04
 * @Description：com.example.cms.web.Controller
 */
@RestController
@Api(tags = "文件上传")
public class UploadController {
    @Autowired
    private IUploadService uploadService;
    // post multipart-form
    @ApiImplicitParams(
            @ApiImplicitParam(name = "file",value = "文件",paramType = "form",dataType ="__file" )
    )
    @PostMapping(value = "/upload",consumes = "multipart/form-data")
    public Result upload(MultipartFile file){
        String path = uploadService.upload(file);
        return Result.success(path);
    }
}
